﻿using BJ.AuthDomain.IService;
using BJ.AuthEntity.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Syspetro.Core.AppDeal;
using Syspetro.Core.DynamicApi;
using Syspetro.Core.GoogleAuth;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BJ.AuthApp
{
    [Authorize]
    public class GoogleAuthApp: BaseDynamicApi
    {
        readonly IGoogleAuthService _googleAuth;
        public GoogleAuthApp(IGoogleAuthService googleAuth)
        {
            _googleAuth = googleAuth;
        }
        /// <summary>
        /// 创建Google验证
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<SpActionResult<GoogleBindingModel>> Generate()
        {
            return await _googleAuth.Generate();
        }
        /// <summary>
        /// 绑定Google验证
        /// </summary>
        /// <param name="Captcha"></param>
        /// <returns></returns>
        public async Task<SpActionResult<bool>> Bind(string Captcha)
        {
            return await _googleAuth.Bind(Captcha);
        }
        /// <summary>
        /// Google验证
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public async Task<SpActionResult<bool>> Validate(string code)
        {
            return await _googleAuth.Validate(code);
        }
    }
}
